package com.frank.work.task;

import com.frank.work.AbstractPipelineNodeTask;
import com.frank.work.BasicInfo;
import com.frank.work.GroupTaskMatch;
import com.frank.work.PipelineNode;
import org.springframework.stereotype.Component;

/**
 * @author 小石潭记
 * @date 2021/12/21 11:03
 * @Description: 任务的根节点
 */
@Component("BaseGroupNodeTask")
public class BaseGroupNodeTask extends AbstractPipelineNodeTask implements GroupTaskMatch {

    @Override
    public Object deal(Object args, PipelineNode pipelineNode) {
        handleTask((BasicInfo) args);
        return args;
    }

    /**
     * 用于生产者那里判断是否需要添加到该队列
     * @param basicInfo
     * @return
     */
    @Override
    public Boolean match(BasicInfo basicInfo) {
        return true;
    }

    /**
     * 模拟业务处理
     * @param basicInfo
     */
    private void handleTask(BasicInfo basicInfo) {
        basicInfo.setId(1);
        basicInfo.setRemark("根节点开始处理");
    }
}
